]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Fix completion handler for empty animations
authorXiaoguang Wang <xwang@suse.com>
Fri, 18 Nov 2016 08:00:01 +0000 (16:00 +0800)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 23 Nov 2016 21:11:00 +0000 (22:11 +0100)
If an onComplete handler is passed to animate(), it is set to run at
the end of the animation via the icon grid's ::animation-done signal.
Currently the signal is connected after starting the animation, with
the result that the handler doesn't run when the animation completes
immediately (because there are no icons to animate). Fix this by only
starting the animation after connecting the signal.

https://bugzilla.gnome.org/show_bug.cgi?id=774381

js/ui/appDisplay.js

index a75d75075de175f045fd314405dfade7cfedab53..5b48d5e6e328ea112a451912d825a9cbcd13e0c4 100644 (file)
@@ -210,6 +210,14 @@ const BaseAppView = new Lang.Class({
     },
 
     animate: function(animationDirection, onComplete) {
+        if (onComplete) {
+            let animationDoneId = this._grid.connect('animation-done', Lang.bind(this,
+                function () {
+                    this._grid.disconnect(animationDoneId);
+                    onComplete();
+            }));
+        }
+
         if (animationDirection == IconGrid.AnimationDirection.IN) {
             let toAnimate = this._grid.actor.connect('notify::allocation', Lang.bind(this,
                 function() {
@@ -225,14 +233,6 @@ const BaseAppView = new Lang.Class({
         } else {
             this._doSpringAnimation(animationDirection);
         }
-
-        if (onComplete) {
-            let animationDoneId = this._grid.connect('animation-done', Lang.bind(this,
-                function () {
-                    this._grid.disconnect(animationDoneId);
-                    onComplete();
-            }));
-        }
     },
 
     animateSwitch: function(animationDirection) {